var t = require;
var e = module;
var o = exports;
var a =
    (this && this.__spreadArrays) ||
    function () {
        for (var t = 0, e = 0, o = arguments.length; e < o; e++) t += arguments[e].length;
        var a = Array(t),
            i = 0;
        for (e = 0; e < o; e++) for (var n = arguments[e], r = 0, s = n.length; r < s; r++, i++) a[i] = n[r];
        return a;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var i = (function () {
    function t() {
        this.isInit = !1;
        this._bundle = "";
        this.prefabData = {};
        this.tag_catAnimal = "catAnimal";
        this.tag_catAnimal2 = "catAnimal2";
        this.tag_carAnimal = "carAnimal";
        this.tag_boxGift = "boxGift";
        this.tag_unLockDlg = "unLockDlg";
        this.tag_upLevelDlg = "upLevelDlg";
        this.tag_gameSkillItem = "gameSkillItem";
        this.tag_boxDevGift = "boxDevGift";
        this.tag_tableFoodView = "tableFoodView";
        this.tag_boxItem = "BoxItem";
        this.tag_buySkillItem = "buySkillItem";
        this.tag_boxReward = "BoxReward";
        this.tag_foodBoxItem = "FoodBoxItem";
        this.tag_rewardItem = "RewardItem";
        this.tag_moveCoin = "moveCoin";
        this.tag_addCoin = "addCoin";
        this.tag_tipDlg = "TipDlg";
        this.tag_ruleItem = "RuleItem";
        this.tag_devEff01 = "devEff01";
        this.tag_devEff02 = "devEff02";
        this.tag_devEff03 = "devEff03";
        this.tag_devEff04 = "devEff04";
        this.tag_devEff05 = "devEff05";
        this.tag_devEff06 = "devEff06";
        this.tag_getCoinNode = "getCoinNode";
        this.tag_tipLevelCom2 = "TipLevelCom2";
        this.tag_invateItem = "invateItem";
        this.tag_zuanShiInvateItem = "ZhuanShiInvateItem";
        this.tag_shopRewardItem = "ShopRewardItem";
        this.tag_typeUnlockItem = "TypeUnlockItem";
        this.tag_CardDayItem = "cardDayItem";
        this.tag_shopItemBuyReward1 = "ShopItemBuyReward1";
        this.tag_PlaySprite = "playSprite";
        this.tag_shopPage1 = "shopPage1";
        this.tag_shopPage2 = "shopPage2";
        this.tag_shopPage3 = "shopPage3";
        this.tag_shopPage4 = "shopPage4";
        this.tag_shopPage5 = "shopPage5";
        this.tag_addCoinItem = "AddCoinItem";
        this.path_basePath1 = "/Fab/";
        this.addKeyPath = [];
        this.loadMaxCount = 0;
        this.curLoadCount = 0;
        this.loadingPreCount = 0;
        this.buildBundle = {};
    }
    t.prototype.init = function (t) {
        if (!this.isInit) {
            this.isInit = !0;
            this.poolerBaseBean = new n();
            this._bundle = t;
            this.addPreFab(this.tag_shopRewardItem, this.path_basePath1);
            this.addPreFab(this.tag_catAnimal, this.path_basePath1);
            this.addPreFab(this.tag_catAnimal2, this.path_basePath1);
            this.addPreFab(this.tag_carAnimal, this.path_basePath1);
            this.addPreFab(this.tag_boxGift, this.path_basePath1);
            this.addPreFab(this.tag_boxDevGift, this.path_basePath1);
            this.addPreFab(this.tag_gameSkillItem, this.path_basePath1);
            this.addPreFab(this.tag_buySkillItem, this.path_basePath1);
            this.addPreFab(this.tag_PlaySprite, this.path_basePath1);
            this.addPreFab(this.tag_shopPage1, this.path_basePath1, 1);
            this.addPreFab(this.tag_shopPage2, this.path_basePath1, 1);
            this.addPreFab(this.tag_shopPage3, this.path_basePath1, 1);
            this.addPreFab(this.tag_shopPage4, this.path_basePath1, 1);
            this.addPreFab(this.tag_shopPage5, this.path_basePath1, 1);
            this.addPreFab(this.tag_shopItemBuyReward1, this.path_basePath1, 1);
            this.addPreFab(this.tag_unLockDlg, this.path_basePath1);
            this.addPreFab(this.tag_upLevelDlg, this.path_basePath1);
            this.addPreFab(this.tag_tableFoodView, this.path_basePath1);
            this.addPreFab(this.tag_boxItem, this.path_basePath1);
            this.addPreFab(this.tag_boxReward, this.path_basePath1);
            this.addPreFab(this.tag_rewardItem, this.path_basePath1);
            this.addPreFab(this.tag_moveCoin, this.path_basePath1);
            this.addPreFab(this.tag_addCoin, this.path_basePath1);
            this.addPreFab(this.tag_addCoinItem, this.path_basePath1);
            this.addPreFab(this.tag_tipDlg, this.path_basePath1);
            this.addPreFab(this.tag_getCoinNode, this.path_basePath1);
            this.addPreFab(this.tag_invateItem, this.path_basePath1);
            this.addPreFab(this.tag_zuanShiInvateItem, this.path_basePath1);
            this.addPreFab(this.tag_devEff01, this.path_basePath1);
            this.addPreFab(this.tag_devEff02, this.path_basePath1);
            this.addPreFab(this.tag_devEff03, this.path_basePath1);
            this.addPreFab(this.tag_devEff04, this.path_basePath1);
            this.addPreFab(this.tag_devEff05, this.path_basePath1);
            this.addPreFab(this.tag_devEff06, this.path_basePath1);
            this.addPreFab(this.tag_foodBoxItem, this.path_basePath1);
            this.addPreFab(this.tag_ruleItem, this.path_basePath1);
            this.addPreFab(this.tag_typeUnlockItem, this.path_basePath1);
            this.addPreFab(this.tag_CardDayItem, this.path_basePath1);
            this.addPreFab(this.tag_tipLevelCom2, this.path_basePath1);
        }
    };
    t.prototype.getNode = function (t) {
        return this.prefabData[t] && this.prefabData[t].pre
            ? this.poolerBaseBean.getNode(this.prefabData[t].pre)
            : null;
    };
    t.prototype.havePreData = function (t) {
        return !(!this.prefabData[t] || !this.prefabData[t].pre);
    };
    t.prototype.putNode = function (t) {
        this.poolerBaseBean.putNode(t);
    };
    t.prototype.addPreFab = function (t, e, o) {
        void 0 === o && (o = 2);
        this.loadMaxCount++;
        this.addKeyPath.push({ key: t, path: e, count: o });
        this.checkAddCount();
    };
    t.prototype.checkAddCount = function () {
        if (this.loadingPreCount < 2 && this.loadMaxCount - this.curLoadCount > 0) {
            this.loadingPreCount++;
            if (this.addKeyPath.length > 0) {
                var t = this.addKeyPath.pop();
                this.addPreFabItem(t.key, t.path, t.count);
            }
        }
    };
    t.prototype.addPreFabItem = function (t, e, o) {
        var a = this;
        void 0 === o && (o = 2);
        this.buildBundle[this._bundle]
            ? this.addBundle(this.buildBundle[this._bundle], t, e, o)
            : cc.assetManager.loadBundle(this._bundle, function (i, n) {
                if (n) {
                    a.buildBundle[a._bundle] = n;
                    a.addBundle(n, t, e, o);
                } else {
                    a.loadingPreCount--;
                    a.curLoadCount++;
                    a.checkAddCount();
                }
            });
    };
    t.prototype.addBundle = function (t, e, o, a) {
        var i = this;
        void 0 === a && (a = 2);
        t.load(o + e, cc.Prefab, function (t, o) {
            i.curLoadCount++;
            i.loadingPreCount--;
            i.checkAddCount();
            if (o) {
                i.prefabData[e] = { pre: o, key: e };
                console.log("QLooperNode ----------------- 添加key" + e);
                for (var n = 0; n < a; n++)
                    setTimeout(function () {
                        i.putNode(cc.instantiate(o));
                    }, 50 * n);
            }
        });
    };
    return t;
})(),
    n = (function () {
        function t() {
            this._poolDict = {};
        }
        t.prototype.getNode = function (t, e) {
            void 0 === e && (e = null);
            for (var o = [], a = 2; a < arguments.length; a++) o[a - 2] = arguments[a];
            var i,
                n = t instanceof cc.Node ? t.name : t.data.name,
                r = "" + n.substring(0, 1).toUpperCase() + n.substring(1);
            if (this._poolDict.hasOwnProperty(n)) {
                var s = this._poolDict[n];
                i = s.size() > 0 ? s.get.apply(s, o) : this._getInstantiateNode(t, e, r, o);
            } else {
                this._poolDict[n] = new cc.NodePool(r);
                i = this._getInstantiateNode(t, e, r, o);
            }
            e && i.setParent(e);
            return i;
        };
        t.prototype.putNode = function (t) {
            if (t) {
                var e,
                    o = t.name;
                if (this._poolDict.hasOwnProperty(o)) e = this._poolDict[o];
                else {
                    e = new cc.NodePool();
                    this._poolDict[o] = e;
                }
                e.put(t);
            }
        };
        t.prototype.clearPool = function (t) {
            var e = "string" == typeof t ? t : t.data.name;
            this._poolDict.hasOwnProperty(e) && this._poolDict[e].clear();
        };
        t.prototype._getInstantiateNode = function (t, e, o, i) {
            var n,
                r = cc.instantiate(t);
            null == e || e.addChild(r);
            var s = r.getComponent(o);
            null === (n = null == s ? void 0 : s.reuse) || void 0 === n || n.call.apply(n, a([s], i));
            return r;
        };
        return t;
    })(),
    r = new i();
window.QLooperNode = r;
o.default = r;
